#include <stdlib.h>

#include "direction.h"


const char* dir_names[DIR_MAX] = {
    "DIR_UP",
    "DIR_UP_RIGHT",
    "DIR_RIGHT",
    "DIR_DOWN_RIGHT",
    "DIR_DOWN",
    "DIR_DOWN_LEFT",
    "DIR_LEFT",
    "DIR_UP_LEFT",
};


const char* DirectionToStr(int direction) {
    return dir_names[direction];
}

int NormDirection(int direction) {
    if (direction >= DIR_MAX)
        return direction - DIR_MAX;
    if (direction < 0)
        return direction + DIR_MAX;
    return direction;
}

int DeltaDirection(int dir_a, int dir_b) {
    return abs(dir_a - dir_b);
}
